package com.sto.stoapp.thread;

import android.content.Context;
import android.util.Log;

import com.sto.stoapp.db.StoFilePreference;
import com.sto.stoapp.jpush.HttpGetControls;
import com.sto.stoapp.util.NetUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by wj on 2017-01-06.
 *
 * 代收货款开关获取
 */

public class GetPayMentOnOffThread extends Thread{

    private Context context;

    public GetPayMentOnOffThread(Context context){
        this.context=context;
    }

    @Override
    public void run() {
        super.run();

        //判断是否有网络连接
        if(!NetUtil.isNetworkAvailable(context)){
            return;
        }

        String result= HttpGetControls.getPayMentOnOff();
        Log.e("wj","代收货款开关:"+result);
        try {
            if(null!=result){
                JSONObject jsonObject=new JSONObject(result);
                int msg=jsonObject.getInt("message");
                StoFilePreference.getInstance(context).setPayMentOnOff(msg);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}


